package games.puzzle8;

import gps_api.State;

public class Puzzle8State implements State{
	static final int SIZE_TABLE=3;
	protected int [][]table;
	protected int emptyPos;
	
	public Puzzle8State(){
		table= new int[SIZE_TABLE][SIZE_TABLE];
	}
	
	@Override
	public boolean equals(Object arg0){
		boolean ans=true;
		Puzzle8State state;
		
		if(arg0 instanceof Puzzle8State){
			state= (Puzzle8State)arg0;
			
			for(int x=0; x<SIZE_TABLE && ans; x++){
				for(int y=0; y<SIZE_TABLE && ans; y++){
					if(table[x][y]!=state.table[x][y]){
						ans= false;
					}
						
				}
			}
			
		}else{
			ans= false;
		}
		
		return ans;
		
	}
	
	@Override
	public String toString(){
		String ans= new String();
		
		
		for(int x=0; x<SIZE_TABLE; x++){
			ans+=" --- --- --- ";
			ans+= '\n';
			for(int y=0; y<SIZE_TABLE; y++){
				ans+="| " + table[x][y]+ " ";
			}
			ans+="|"+ '\n';
		}
		ans+=" --- --- --- ";
		
		return ans;
		
	}
	
	public void setEmptyPos(int y, int x){
		emptyPos= y*SIZE_TABLE + x;
	}

}
